// components/commentItem/index.js
import { Topic } from "../../model/Topic.js";
const topic = new Topic();
Component({
    /**
     * 组件的属性列表
     */
    properties: {
        message: {
            type: Object,
            value: {}
        }
    },

    /**
     * 组件的初始数据
     */
    data: {

    },

    /**
     * 组件的方法列表
     */
    methods: {
        /**
         *取消关注
         */
        unfollow(e) {
            const id = this.data.message.PostId;
            topic.follow({
                    type: "unfollow",
                    id: id
                })
                .then(res => {
                    wx.showToast({
                        title: '取消成功'
                    })
                    this.triggerEvent("unfollow", {
                        id: id
                    });
                })
                .catch(err => {
                    wx.showToa({
                        title: err.message
                    });
                });
        },
        /**
         * 跳转详情
         */
        gotoDetail() {
            wx.navigateTo({
                url: `/pages/detail/index?id=${this.data.message.PostId}`,
            });
        }
    }
})